package net.prasenjit.test.webservice.endpoint;

import net.prasenjit.test.core.service.TestService;
import net.prasenjit.test.webservice.contract.DoSomethingRequest;
import net.prasenjit.test.webservice.contract.DoSomethingResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

@Endpoint
public class WSEndpoint {

    @Autowired
    private TestService testService;

    @PayloadRoot(localPart = "doSomethingRequest", namespace = "http://test.prasenjit.net/webservice/contract")
    @ResponsePayload
    public DoSomethingResponse doSomething(@RequestPayload DoSomethingRequest req) {
        return new DoSomethingResponse(testService.doSomething(req.getName()));
    }
}
